package src.com.hpu.service;

import com.hpu.callback.DownloadCallback;
import com.hpu.constants.HttpConstants;
import com.hpu.constants.ShareConstants;
import com.hpu.constants.UrlConstants;
import com.hpu.tools.InternetTools;
import com.hpu.tools.OkHttpTools;
import com.hpu.tools.ShareTools;

import android.content.Context;
import android.os.Handler;

/**
 * 下载业务类，负责访问网络获取最新公告的内容
 * @author Administrator
 *
 */
public class DownloadService{

	private Handler handler;
	
	private Context context;
	
	public DownloadService(Handler handler,Context context) {
		this.handler=handler;
		this.context=context;
	}

	public void download(String fileId,String fileName) {
		if(InternetTools.statusInternet(context)==InternetTools.NO_INTERNET)
			handler.sendEmptyMessage(HttpConstants.NO_INTERNET);
		else
		OkHttpTools.postByCookie(UrlConstants.getNoticeDownlaodUrl(), 
				ShareTools.get(context, ShareConstants.STORE_LOGINCOOKIE, "").toString(), 
				new DownloadCallback(handler),
				new String[]{"fileID","fileName"},new String[]{fileId,fileName});
	}

}
